// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SourceFile

package com.sgame.android.social;

import java.util.*;
import org.json.*;

// Referenced classes of package com.mobage.global.android.social.util:
//            PageOptionsEntry

public class PageOptionsResult
{

    public PageOptionsResult()
    {
        setCount(0);
        setTotal(0);
        setEntry(null);
        setStart(0);
        setEntries(null);
    }

    public PageOptionsResult(JSONObject jsonObject)
        throws JSONException
    {
		ArrayList<PageOptionsEntry> arraylist = new ArrayList<PageOptionsEntry>();
		PageOptionsEntry obj = null;
        setCount(jsonObject.getInt("itemsPerPage"));
        setTotal(jsonObject.getInt("totalResults"));
        setEntry(jsonObject.getJSONArray("entry"));
        for(int i = 0; i < e.length(); i++)
        {
            Object obj1 = e.getJSONObject(i);
            obj = new PageOptionsEntry(((JSONObject) (obj1)));
            arraylist.add(obj);
        }

        setEntries(arraylist);
        setStart(jsonObject.getInt("startIndex"));
    }

    public PageOptionsResult(List<PageOptionsEntry> entries)
    {
        setCount(entries.size());
        setTotal(entries.size());
        setStart(1);
        setEntries(entries);
        e = new JSONArray();
        PageOptionsEntry pageoptionsentry;
        for(Iterator<PageOptionsEntry> item = entries.iterator(); item.hasNext(); e.put(pageoptionsentry.getValue()))
            pageoptionsentry = (PageOptionsEntry)item.next();

    }

    public List<PageOptionsEntry> getEntries()
    {
        return a;
    }

    public void setEntries(List<PageOptionsEntry> entries)
    {
        a = entries;
    }

    public int getTotal()
    {
        return b;
    }

    public void setTotal(int total)
    {
        b = total;
    }

    public int getStart()
    {
        return c;
    }

    public void setStart(int start)
    {
        c = start;
    }

    public int getCount()
    {
        return d;
    }

    public void setCount(int count)
    {
        d = count;
    }

    public String toString()
    {
        JSONArray jsonarray;
        JSONObject jsonobject;
        PageOptionsEntry iterator;
        jsonarray = new JSONArray();
        if(getEntries() == null)
            return null;
    	jsonobject = new JSONObject();
    	try {
			jsonobject.put("totalResults", (new StringBuilder()).append(getTotal()).toString());
	    	jsonobject.put("itemsPerPage", (new StringBuilder()).append(getCount()).toString());
	    	jsonobject.put("entry", jsonarray);
	    	jsonobject.put("startIndex", (new StringBuilder()).append(getStart()).toString());
	    	jsonarray.put(jsonobject);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        int i;
        for(i = 0; i < a.size(); i++)
        {
        	iterator = a.get(i);
        	jsonarray.put(iterator);
        }
        return jsonarray.toString();
    }

    public JSONArray getEntry()
    {
        return e;
    }

    public void setEntry(JSONArray entry)
    {
        e = entry;
    }

    private List<PageOptionsEntry> a;
    private int b;
    private int c;
    private int d;
    private JSONArray e;
}
